<?php
include("connect.php");

class Player
{
	public $playerID;
	public $resources;
	
	function __construct($PlayerID) 
	{
		$this->playerID = $PlayerID;
		$query = "SELECT * FROM resources";
		$result = mysql_query($query);
		$i=0;
		while($row = mysql_fetch_assoc($result))
		{
			$this->resources[$i] = $row;
			$i++;
		}
		
		$i=0;
		while($i<sizeof($this->resources))
		{
			$query = "SELECT * FROM k_resources WHERE resID='".$this->resources[$i]['id']."' AND playerID = '$this->playerID'";
			$result = mysql_query($query);
			if($row = mysql_fetch_assoc($result))
			{
				$this->resources[$i]['Number'] = $row['value'];
			}
			$i++;
		}
   	}
	
	function DrawResources()
	{
		$i = 0;
		while($i<sizeof($this->resources))
		{
			if(isset($this->resources[$i]['Number']))
			{
				echo "<div class='Reswrapper' style='margin-top:".(Round($i/5,0,PHP_ROUND_HALF_DOWN)*16).";margin-left:".(($i*64)+$i*5)."'>";
				echo "<img src='".$this->resources[$i]['url']."' />";
					echo "<div class='ResValue'>";
						echo $this->resources[$i]['Number'];
					echo "</div>";
				echo "</div>";
			}
			$i++;
		}
	}
}
?>